package jdbc.dm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import jdbc.DatabaseEnum.driverClass;

public class TestDM {

    /***
     * jdbc:dm://192.168.11.104:5236/99999,user:sysdba,pass:123456789
     *
     * jdbc:dm://192.168.11.200:6000 user:sysdba,pass:111111111
     */
    private static final String DM_JDBC_URL_TEMPLATE = "jdbc:dm://%s:%s/%s";

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        StringBuilder url = new StringBuilder();
        Class.forName(driverClass.DM_DRIVER_CLASS.toString());
        url.append(String.format(DM_JDBC_URL_TEMPLATE, "192.168.11.200", "6000", ""));
        try (
            Connection connection = DriverManager.getConnection(url.toString(), "SYSDBA", "111111111")) {

            PreparedStatement ps = connection.prepareStatement("select * from V$TABLESPACE");
            ResultSet rs = ps.executeQuery();
            System.out.println(rs);
            while (rs.next()) {
                System.out.println(rs.getString(1));
            }
            System.out.println(connection);
        } catch (Exception e) {
            e.printStackTrace();

        }
    }
}
